package com.sample.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class HttpStandardServlet extends HttpServlet {

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {

	    System.out.println("HttpStandardServlet Start doPost");

	    sleep(3000);

	    String param1 = req.getParameter("param1");
		String param2 = req.getParameter("param2");

		resp.getOutputStream().print("POST " + param1 + " " + param2);

       System.out.println("HttpStandardServlet End doPost");
	}

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {

	    System.out.println("HttpStandardServlet Start doGet");

        String param1 = req.getParameter("param1");
        String param2 = req.getParameter("param2");

        resp.getOutputStream().print("GET " + param1 + " " + param2);

       System.out.println("HttpStandardServlet End doGet");
	}

	private void sleep(int sec) {
		try {
			Thread.sleep(sec);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}

}
